﻿var domain = "http://www.artseasy.cn";
function getRootPath() {
	var curWwwPath = window.document.location.href;
	var pathName = window.document.location.pathname;
	var pos = curWwwPath.indexOf(pathName);
	var localhostPaht = curWwwPath.substring(0, pos);
	var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
	return (localhostPaht + projectName);
}

/*
 * 方法名 authorised(redirectPath, state)
 * 参数 redirectPath 请求地址
 * 参数 state 请求参数 如果不需要填""
 * 
 */
function authorised(redirectPath, state) {
	var basePath = getRootPath();
	
	$.ajax({
		type : "post",
		url : domain + "/app/weixin/authorisedParam.htm",
		dataType : "json",
		success : function(data) {
		
			var appId = data.appId;
			var url = "https://open.weixin.qq.com/connect/oauth2/authorize?" +
						"appid=" + appId + 
						"&redirect_uri=" + domain + redirectPath + 
						"&response_type=code" +
						"&scope=snsapi_userinfo" +
						"&state=" +state+ 
						"#wechat_redirect";
			window.location.href = url;
		}
	});
}

function getPayParam(openId, amount, body, notifyURL, orderType){
	var s1 = "openId=" + openId +"&amount=" + amount + "&body=" + body + "&notify_url=" + notifyURL + "&order_type=" + orderType; 
	return s1;
}